import http from '../http'
import {
  dreamQuestionBank,
  SMART_HOMEWORK,
  aiLearnPad,
  aiLearn
} from '../host.js'

const API = {
  getCourseList: '/v1/courses/class',
  getLayeredStudentList: '/api/v1/targetPractice/getLayeredStudentList',
  postCreateLayer: '/api/v1/taskCenterNew/createLayer',
  getLayerIds: '/api/v1/taskCenterNew/getLayerInfo',
  postAddStudent: '/api/v1/taskCenterNew/addStudent',
  postCourseTask: '/api/v1/taskCenterNew/courseTaskSubmit',
  getStudentByLayerId: '/api/v1/taskCenterNew/getStudentByLayerId',
  getTaskList: '/api/v1/taskCenterNew/getTaskList',
  getOssToken: '/v1/common/upload/ststoken',
  postPracticeTask: '/api/v1/taskCenterNew/createQuestionTask',
  getPracticeDetail: '/api/v1/taskCenterNew/viewTaskDesc',
  getQuestionList: '/api/v1/taskCenterNew/viewTaskQuestion',
  getChapterInfo: '/api/v1/taskCenterNew/chapterInfo',
  getCourseGrade: '/api/v1/taskCenterNew/getGrade',
  getTaskUrge: '/api/v1/taskCenterNew/taskUrge',
  getQuestionByTaskId: '/api/v1/taskCenterNew/getQuestionByTaskId',
  postTeacherFeedBack: '/api/v1/taskCenterNew/teacherFeedBack',
  postSubmitWrongTopic: '/api/v1/taskCenterNew/submitWrongTopic',
  getTaskDetail: '/api/v1/taskCenterNew/taskOfDetail',
  getScoreDetail: '/api/v1/taskCenterNew/gradeOfDetail',
  getWrongDetail: '/api/v1/taskCenterNew/wrongQuestionOfDetail',
  getIsRetrain: '/api/v1/taskCenterNew/createTaskRetrainQuestion',
  getClassComparison: '/api/v1/taskCenterNew/getClassComparison',
  getScoreDistribution: '/api/v1/taskCenterNew/getScoreDistribution',
  getQuestionAverageAccuracy:
    '/api/v1/taskCenterNew/getQuestionAverageAccuracy',
  getQuestionAverageAccuracyAndRank:
    '/api/v1/taskCenterNew/getQuestionAverageAccuracyAndRank',
  getStudentAnswersForTopic: '/api/v1/taskCenterNew/getStudentAnswersForTopic',
  getCompareResponseStatistics:
    '/api/v1/taskCenterNew/compareResponseStatistics',
  getKnowledgeReport: '/api/v1/taskCenterNew/getKnowledgeReport',
  updateRetrainConfig: '/api/v1/taskCenterNew/retrainConfig',
  getTaskInfoById: '/api/v1/taskCenterNew/getTaskBaseInfo',
  getResponseOfDetail: '/api/v1/taskCenterNew/responseOfDetail',
  postCollect: '/v1/action/collect',
  postLayeredStudentList: '/api/v1/targetPractice/updateLayeredStudentList',
  deleteTask: '/api/v1/taskCenterNew/deleteTask',
  getPendingTaskOfDetail: '/api/v1/taskCenterNew/pendingTaskOfDetail',
  postAddTask: '/api/v1/questionBasket/insertQuestionToBasket',
  getBasketQuestion: '/api/v1/questionBasket/getBasketQuestion',
  genPaper: '/v1/paper/personal',
  getResponseStatistics: '/api/v1/taskCenterNew/responseStatistics',
  postUseQuestionList: '/v1/add/use/count',
  getRelationTask: '/api/v1/taskCenterNew/getRelationTask',
  getStudentCompleteStatistics:
    '/api/v1/taskCenterNew/studentCompleteStatistics',
  getTaskStudentResponse: '/api/v1/taskCenterNew/getTaskStudentResponse',
  deleteStudentTask: '/api/v1/taskCenterNew/deleteStudentTask',
  getStudentTaskResponseDetail:
    '/api/v1/taskCenterNew/getStudentTaskResponseDetail',
  getRetrainStatistics: '/api/v1/taskCenterNew/retrainStatistics',
  getStudentRetrainTask: '/api/v1/taskCenterNew/getStudentRetrainTask',
  getQuestionType: '/v1/get/question/type',
  getStudentRetrainQuestion: '/api/v1/taskCenterNew/getStudentRetrainQuestion',
  getPracticeData: '/api/v1/targetPractice/getPracticeData',
  getQuestionCount: '/v2/wrong/question/count-new',
  getWrongTarget: '/v1/wrong/web/wrong/target',
  getTaskCount: '/v2/wrong/question/task/count'
}

// 获取所有课程信息
export function getCourseList(params) {
  return http.get(dreamQuestionBank + API.getCourseList, {
    params
  })
}

// 获取所有课程章节
export function getChapterList(courseId) {
  return http.get(dreamQuestionBank + `/v1/courses/${courseId}/chapters`)
}

// 获取课程所分享的班级
export function getShareClassList(courseId, params) {
  return http.get(dreamQuestionBank + `/v1/courses/${courseId}/share_class`, {
    params
  })
}

// 获取分层学生列表
export function getLayeredStudentList(params) {
  return http.get(aiLearn + API.getLayeredStudentList, {
    params
  })
}

// 创建班级分层id
export function postCreateLayer(data) {
  return http.post(aiLearn + API.postCreateLayer, data, {
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

// 获取班级分层id
export function getLayerIds(params) {
  return http.get(aiLearn + API.getLayerIds, {
    params,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

// 根据分层id获得学生信息
export function getStudentByLayerId(params) {
  return http.get(aiLearn + API.getStudentByLayerId, {
    params,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}
// 获取任务列表
export function getTaskList(params) {
  return http.get(aiLearn + API.getTaskList, {
    params,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

// 向分层中加入学生
export function postAddStudent(data) {
  return http.post(aiLearn + API.postAddStudent, data, {
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

// 发布课程任务
export function postCourseTask(data) {
  return http.post(aiLearn + API.postCourseTask, data, {
    headers: {
      'Content-Type': '	application/json'
    }
  })
}

// 九九八十一难接口
// 统一发布任务接口
export function postPracticeTask(data) {
  return http.post(aiLearn + API.postPracticeTask, data, {
    headers: {
      'Content-Type': '	application/json'
    }
  })
}

// 获取阿里云token
export function getOssToken(policy = 0) {
  return http.get(SMART_HOMEWORK + API.getOssToken, {
    policy
  })
}

// 获取习题错题任务详情
export function getPracticeDetail(params) {
  return http.get(aiLearn + API.getPracticeDetail, {
    params
  })
}

// 查看任务下的题目
export function getQuestionList(params) {
  return http.get(aiLearn + API.getQuestionList, {
    params
  })
}

// 获取章节学情
export function getChapterAca(params) {
  return http.get(aiLearn + API.getChapterInfo, {
    params
  })
}

// 课程任务成绩列表
export function getCourseGrade(params) {
  return http.get(aiLearn + API.getCourseGrade, {
    params
  })
}

// 催交作业
export function getTaskUrge(params) {
  return http.get(aiLearn + API.getTaskUrge, {
    params
  })
}

// 根据任务获取题目
export function getQuestionByTaskId(params) {
  return http.get(aiLearn + API.getQuestionByTaskId, {
    params
  })
}

// 老师批改
export function postTeacherFeedBack(data) {
  return http.post(aiLearn + API.postTeacherFeedBack, data)
}

// 根据任务获取题目
export function postSubmitWrongTopic(data) {
  return http.post(aiLearn + API.postSubmitWrongTopic, data)
}

// 获取任务详情
export function getTaskDetail(params) {
  return http.get(aiLearn + API.getTaskDetail, {
    params
  })
}

// 获取成绩详情
export function getScoreDetail(params) {
  return http.get(aiLearn + API.getScoreDetail, {
    params
  })
}

// 获取错题重练详情
export function getWrongDetail(params) {
  return http.get(aiLearn + API.getWrongDetail, {
    params
  })
}

// 判断是否重练
export function getIsRetrain(params) {
  return http.get(aiLearn + API.getIsRetrain, {
    params
  })
}

// 获取各班对比
export function getClassComparison(params) {
  return http.get(aiLearn + API.getClassComparison, {
    params
  })
}

// 获取正确率区间人数
export function getScoreDistribution(params) {
  return http.get(aiLearn + API.getScoreDistribution, {
    params
  })
}

// 各个题目平均正确率
export function getQuestionAverageAccuracy(params) {
  return http.get(aiLearn + API.getQuestionAverageAccuracy, {
    params
  })
}

// 列表展示各个题目详情
export function getQuestionCompareList(params) {
  return http.get(aiLearn + API.getQuestionAverageAccuracyAndRank, {
    params
  })
}

export function getCompareResponseStatistics(params) {
  return http.get(aiLearn + API.getCompareResponseStatistics, {
    params
  })
}

// 单题下学生的作答情况对比
export function getStudentAnswersForTopic(params) {
  return http.get(aiLearn + API.getStudentAnswersForTopic, {
    params
  })
}

// 知识点对比分析
export function getKnowledgeReport(params) {
  return http.get(aiLearn + API.getKnowledgeReport, {
    params
  })
}

// 修改重练配置
export function updateRetrainConfig(params) {
  return http.get(aiLearn + API.updateRetrainConfig, { params })
}

// 题目的作答详情
export function getResponseOfDetail(params) {
  return http.get(aiLearn + API.getResponseOfDetail, {
    params
  })
}

// 根据任务ID获取详情（不含题目）
export function getTaskInfoById(params) {
  return http.get(aiLearn + API.getTaskInfoById, {
    params
  })
}

// 数据埋点
export function postCollect(data) {
  return http.post(aiLearnPad + API.postCollect, data)
}

// 更新分层
export function postLayeredStudentList(data) {
  return http.post(aiLearn + API.postLayeredStudentList, data)
}

// 删除任务
export function deleteTask(params) {
  return http.delete(aiLearn + API.deleteTask, { params })
}

// 待发布任务详情
export function getPendingTaskOfDetail(params) {
  return http.get(aiLearn + API.getPendingTaskOfDetail, {
    params
  })
}

// 从试题篮获取题目
export function getBasketQuestion(params) {
  return http.get(aiLearn + API.getBasketQuestion, {
    params
  })
}

// 向试题篮中添加题目
export function postAddTask(data) {
  return http.post(aiLearn + API.postAddTask, data)
}

// 根据试题篮生成试卷
export function postGenPaper(data) {
  return http.post(dreamQuestionBank + API.genPaper, data)
}

// 题目引用次数
export function postUseQuestionList(data) {
  return http.post(dreamQuestionBank + API.postUseQuestionList, data)
}

// 题目的作答统计
export function getResponseStatistics(params) {
  return http.get(aiLearn + API.getResponseStatistics, {
    params
  })
}

// 题目的作答统计
export function getRelationTask(params) {
  return http.get(aiLearn + API.getRelationTask, {
    params
  })
}

// 学生的完成统计
export function getStudentCompleteStatistics(params) {
  return http.get(aiLearn + API.getStudentCompleteStatistics, {
    params
  })
}

// 举一反三 获取某一任务的学生作答情况
export function getTaskStudentResponse(params) {
  return http.get(aiLearn + API.getTaskStudentResponse, {
    params
  })
}

// 举一反三 删除学生的任务
export function deleteStudentTask(params) {
  return http.delete(aiLearn + API.deleteStudentTask, {
    params
  })
}

// 举一反三 获取学生任务下题目的作答详情
export function getStudentTaskResponseDetail(params) {
  return http.get(aiLearn + API.getStudentTaskResponseDetail, {
    params
  })
}

// 错题重练统计（错题反扫用）
export function getRetrainStatistics(params) {
  return http.get(aiLearn + API.getRetrainStatistics, {
    params
  })
}

// 获取学生的错题重练任务(错题反扫)
export function getStudentRetrainTask(params) {
  return http.get(aiLearn + API.getStudentRetrainTask, {
    params
  })
}

// 获取题型
export function getQuestionType(params) {
  return http.get(dreamQuestionBank + API.getQuestionType, {
    params
  })
}

// 获取学生的重练错题(错题反扫)
export function getStudentRetrainQuestion(params) {
  return http.get(aiLearn + API.getStudentRetrainQuestion, {
    params
  })
}

// 错题本订正(错题反扫)
export function getPracticeData(data) {
  return http.post(aiLearn + API.getPracticeData, data, {
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

// 班级知识点错题量-新(知识点会给非叶子节点的赋值)
export function getQuestionCount(data) {
  return http.post(aiLearnPad + API.getQuestionCount, data, {
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

// 错题反扫-个性错题本-知识图谱获取题目
export function getWrongTarget(data) {
  return http.post(aiLearnPad + API.getWrongTarget, data, {
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

// 错题本-Task错题数量目录
export function getTaskCount(data) {
  return http.post(aiLearnPad + API.getTaskCount, data, {
    headers: {
      'Content-Type': 'application/json'
    }
  })
}
